using System.Collections.Generic;

namespace PKGames.Voxel.Analytics
{
	public class BlockInteractionEventGroup
	{
		private readonly Dictionary<string, BlockInteractionEvent> _blockInteractions = new Dictionary<string, BlockInteractionEvent>();

		private readonly string _levelName;

		public BlockInteractionEventGroup(string levelName)
		{
			_levelName = levelName;
		}

		public void BlockAdded(string type, int count)
		{
			if (!_blockInteractions.ContainsKey(type))
			{
				_blockInteractions[type] = new BlockInteractionEvent(_levelName, type);
			}
			_blockInteractions[type].BlocksAdded(count);
		}

		public void BlockRemoved(string type, int count)
		{
			if (!_blockInteractions.ContainsKey(type))
			{
				_blockInteractions[type] = new BlockInteractionEvent(_levelName, type);
			}
			_blockInteractions[type].BlocksRemoved(count);
		}

		public void FinishAndLog()
		{
			foreach (BlockInteractionEvent value in _blockInteractions.Values)
			{
				value.Finish();
				value.Log();
			}
		}
	}
}
